<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h5>欢迎光临vue_开发的收银系统_水果店</h5>
      <h2>苹果10￥/斤，折扣<8折></h2>
      <span>请输入你要购买的斤数<input type="text" v-model="txt" /></span><br />
      <button @click="fn()">结账买单</button>
      <p>
        结账单：总价:{{totalPrice}}￥元折后 折后价：{{countPrice}}￥元
        省了：{{savePrice}}￥元
      </p>
    </div>
    <script src="./vue.js"></script>
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          txt: '',
          totalPrice: '',
          savePrice: '',
          countPrice: ''
        },
        methods: {
          fn() {
            this.totalPrice = this.txt * 10
            this.countPrice = this.txt * 0.8 * 10
            this.savePrice = this.totalPrice - this.countPrice
          }
        }
      })
    </script>
  </body>
</html>
